<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/jspf/adminPage.jspf"%>
    <%@include file="/WEB-INF/jspf/meta/meta.jspf"%>
    <title>学生管理</title>
    <%@include file="/WEB-INF/jspf/css_js/easyui_grid_tools_js.jspf"%>
    <script type="text/javascript"  src="<%=request.getContextPath()%>/static/student/student.js"></script>

    <%@include file="/WEB-INF/jsp/_condition/_condition.jspf"%>
    <script type="text/javascript">
        //子页面接口。子页面处理后的结果，会从此方法传入
        function finallyDoFunction(data){
            //把子页面传来的参数，放到父（当前）页面中的容器来
            //会自动重新发起请求。这时，easyui框架会把我们的页面容器中的对象，一同带去
            $('#dg_student').datagrid({queryParams:{whereSql:data}});
        }

        //异步提交表单
        function check(){
            if($('#file').val()==null||$('#file').val()==''){
                alert("请选择需要上传的Excel文件！")
                return false;
            }
            return true;
        }
        function upload(){
            if(check()==true){
                var formData=new FormData();
                formData.append('file',$('#file')[0].files[0]);
                $.ajax({
                    url: "<%=request.getContextPath()%>/student/upload.json",
                    type: "POST",
                    data: formData,
                    processData:false,
                    contentType:false,
                    success: function (data) {
                        $.messager.show({
                            title:'操作提示',
                            msg:data.msg,
                            timeout:3000,
                            showType:'slide'
                        });
                        $('#dg_student').datagrid('reload');
                        $('#file').clear();

                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        // alert(XMLHttpRequest.status);
                        // alert(XMLHttpRequest.readyState);
                        // alert(textStatus);
                        alert("添加失败");

                    }
                });
            }
        }
    </script>
</head>
<body>

<!-- 显示信息表格 -->
<table id="dg_student" class="easyui-datagrid" pagination="true"
       pageList="[5,10,50,100,200,300,500]" pageSize="5"
       data-options="
                    fit:true
                    ,url:'<%=request.getContextPath()%>/student/selectList.json'
                    ,fitColumns:false
                    ,singleSelect:true
                    ,toolbar:'#tb'						<%--数据网格(DataGrid)面板的头部工具栏--%>
                    ,onRowContextMenu:f_contextMenu_student		<%--鼠标右键事件--%>
                    ">
    <thead>
    <tr>
        <th data-options="field:'studentId',width:200,sortable:true">学生编号</th>
        <th data-options="field:'studentName',width:100,sortable:true">学生名称</th>
        <th data-options="field:'studentAccount',width:200,align:'center',sortable:true">学生账号</th>

        <th data-options="field:'studentStyleName',width:100,align:'center'">就读情况</th>
        <th data-options="field:'gradeName',width:100,align:'center'">班级</th>
        <th data-options="field:'subjectName',width:100,align:'center'">科目</th>
        <th data-options="field:'roomName',width:100,align:'center'">宿舍</th>
    </tr>
    </thead>
</table>

<!-- 工具栏使用 -->
<div id="tb" style="padding: 5px; height: auto">
    <div>
        <c:if test="${code.contains('student:delete')}">
            <a href="#" class="easyui-linkbutton"  iconCls="icon-remove" onclick="$('#dlg_dell').dialog('open')">删除</a>
        </c:if>
        <c:if test="${code.contains('student:update')}">
            <a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="f_student_update()">修改</a>
        </c:if>
        &nbsp;&nbsp;&nbsp;  <%-- 占位符 --%>

<%--        <a href="#"--%>
<%--           class="easyui-linkbutton" iconCls="icon-search"--%>
<%--           onclick="f_common_condition('Student','finallyDoFunction') ">查询</a>--%>

        <c:if test="${code.contains('student:select')}">
            <a href="<%=request.getContextPath() %>/student/studentList/down" class="easyui-linkbutton" plain="true" >导出Excel数据</a>
        </c:if>
        <c:if test="${code.contains('student:insert')}">
            <form id="upfile" style="display: inline;">
                <input id="file" name="file" type="file" style="width: 170px"/>
                <input type="button" value="导入Excel数据"  onclick="upload()"/>
            </form>
        </c:if>
    </div>
</div>



<!--DataGrid行 右键菜单
    //菜单入口
    function f_contextMenu_subject()
-->
<%@include file="/WEB-INF/jsp/student/_menuGrid.jspf"%>

<!-- 删除对话框架 及后台数据处理
     "$('#dlg').dialog('open')  打开对话框架
     "$('#dlg').dialog('close') 关闭对话框架
-->
<%@include file="/WEB-INF/jsp/student/_dell.jspf"%>

<!--修改对话框架 及后台数据处理
    启动入口
    function f_subject_update()
-->
<%@include file="/WEB-INF/jsp/student/_update.jspf"%>

<!--修改对话框架 及后台数据处理
    启动入口
    function f_subject_oneDetail()
-->
<%@include file="/WEB-INF/jsp/student/_oneDetail.jspf"%>
</body>
</html>

